package com.btb.adapter.model;

import java.util.Date;
import java.util.Objects;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 *
 */
@Builder
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@Data
@ToString
public class TaskConfig {
    private Integer id;

    /**
     * 事件类型
     */
    private String taskName;

    /**
     * 从区块链上调用检查的时间
     */
    private Long taskFrequency;

    /**
     * 初始开始的区块
     */
    private Long initBlockNumber;

    /**
     * 从那个区块开始检查
     */
    private Long startBlockNumber;

    /**
     * 进度，应该是处于start到start + step_num之间
     */
    private Long progressBlockNumber;

    /**
     * 一个循环周期是多少块0-5　5-10
     */
    private Long stepNum;

    /**
     * 偏移多个少区块，才进行下一个操作，比如通知远程
     */
    private Long offset;

    /**
     *  状态0启动，１停止
     */
    private Long status;

    /**
     * 推送重试次数
     */
    private Integer retryTimes;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 修改时间
     */
    private Date updatedTime;


	@Override
	public boolean equals(Object obj) {
		final TaskConfig another = (TaskConfig) obj;
		if (Objects.isNull(another))
			return false;
		if (!this.taskFrequency.equals(another.getTaskFrequency())
				|| !Objects.equals(this.status, another.getStatus())
				|| !Objects.equals(this.stepNum, another.getStepNum())
				|| !Objects.equals(this.taskName, another.getTaskName())
				|| !Objects.equals(this.startBlockNumber, another.getStartBlockNumber())) {
			return false;
		}
		return true;
	}

	@Override
	public int hashCode() {
		return super.hashCode();
	}
}